<?php
/**
 * The MIT License
 *
 * Copyright (c) <year> <copyright holders>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @author Damiano Ciarla
 * @package core
 * @subpackage exception
 */
class BXD_Exception extends Exception
{
	/**
	 * Il nome della classe di configurazione dell'applicazione non è corretto
	 */
	const CONFIG_FILES_INCORRECT_DECLARATION_CLASS_NAME = 1;

	/**
	 * La classe di configurazione non estende la classe corretta
	 */
	const CONFIG_FILES_NOT_EXTENDS_THE_CORRECT_CLASS = 2;

	/**
	 * Il controller non estende la classe corretta
	 */
	const VIEW_NOT_EXISTS = 3;

	/**
	 * In caso di controller e action non trovati e nessuna configurazione impostata per
	 * il reRoute a controller/action 404
	 */
	const CONFIGURATION_NOT_SETTINGS_FOR_404 = 4;

	/**
	 * La classe di sistema non esiste
	 */
	const SYSTEM_CLASS_NOT_EXISTS = 5;

	/**
	 * La classe che si sta cercando di includere non esiste
	 */
	const CLASS_NOT_FOUND = 6;

	public function __construct($params, $code)
	{
		switch($code)
		{
			case self::CONFIG_FILES_INCORRECT_DECLARATION_CLASS_NAME :
				$message = sprintf("Incorrect class name into '%s' file in the 'config' folder", $params . '.php');
				break;

			case self::CONFIG_FILES_NOT_EXTENDS_THE_CORRECT_CLASS :
				$message = sprintf("'%s' in the 'config' folder not extends the correct class", $params . '.php');
				break;

			case self::VIEW_NOT_EXISTS :
				$message = sprintf("The view '%s' not exists", $params);
				break;

			case self::CONFIGURATION_NOT_SETTINGS_FOR_404 :
				$message = "You must specify values ​​for parameters controller_404 and action_404 in the BXD_Config_Action";
				break;

			case self::SYSTEM_CLASS_NOT_EXISTS :
				$message = sprintf("The system class '%s' not found into BXD core", $params);
				break;

			case self::CLASS_NOT_FOUND :
				$message = sprintf("Class '%s' not found into '%s' folder", $params[0], $params[1]);
				break;
		}

		parent::__construct($message, $code);
	}
}
?>